import java.util.Arrays;
import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/3/21 20:26
 */

public class Solution {
    public void moveZeros(int[] nums){
        for (int cur = 0,dest = -1; cur < nums.length; cur++) {
            if(nums[cur] != 0){
                dest++;
                int tmp = nums[cur];
                nums[cur] = nums[dest];
                nums[dest] = tmp;
            }
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int len = in.nextInt();
            int[] nums = new int[len];
            for (int i = 0; i < len; i++) {
                nums[i] = in.nextInt();
            }
            Solution solution = new Solution();
            solution.moveZeros(nums);
            System.out.println(Arrays.toString(nums));
        }
    }
}